home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / castools.zip / FAXCANCE.C < prev    next >
Text File  |  1990-01-10  |  1KB  |  57 lines

  1.  
  2.  
  3. /*
  4.    FAXCANCE.C  A high-level CAS Toolkit function.
  5.  
  6.    This function cancels or aborts a Task Event.
  7.  
  8.    INPUT:  An event handle.
  9.  
  10.    OUTPUT: Returns the event handle if successful, otherwise 0.
  11. */
  12.  
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <cas.h>
  16. #include <fax.h>
  17.  
  18. int pascal FAXCancelTask(int EventHandle)
  19. {
  20.   int retval = 0;                 /* for return value of CAS calls */
  21.   CECS CurrentEventInfo;          /* for call to CASGetCurrentEventStatus */
  22.  
  23.   FAXerrno = CASerrorcode = 0;      /* They keep it if nothing goes wrong */
  24.  
  25.   /* If the event is currently executing, abort it */
  26.   if (EventHandle == CASGetCurrentEventStatus(&CurrentEventInfo)) {
  27.     retval = CASAbortCurrentEvent(); /* Changes Task Control File to a Log */
  28.     if (retval < 0) {                /* Control File of an aborted event */
  29.       FAXerrno = ABORTCURRENT;
  30.       goto finish;
  31.     }
  32.     else {
  33.       FAXerrno = EVENTWASCURRENT;    /* Warning only */
  34.       goto finish;
  35.     }
  36.   }
  37.   else {
  38.     retval = CASDeleteFile(EventHandle, 0, TASK_QUEUE);
  39.     if (retval) {
  40.       FAXerrno = DELETEFILE;
  41.       goto finish;
  42.     }
  43.     else {
  44.       retval = EventHandle;
  45.     }
  46.   }
  47.  
  48. finish:
  49.   if (retval < 0) {
  50.     CASerrorcode = -retval;
  51.     return(0);
  52.   }
  53.   else {
  54.     return(retval);
  55.   }
  56. }
  57.